$(function () {
	var params = {};
	var ajax = new $ax(Sys.backendPath + "/analysis/qcportal/qcDetailList", function (data) {
		$('#riskEvalInfoTable').bootstrapTable("destroy");//先销毁原来的表格
		$('#riskEvalInfoTable').bootstrapTable({
			data: data,
			height: 340,
			striped: false,  //隔行变色
			// minimumCountColumns: 2,
			clickToSelect: false,
			silentSort: false,
			smartDisplay: false,
			escape: false,
			maintainSelected: true,
			cache: false,
			detailView: false, //父子表
			columns: [
				{title: '序号', field: 'id', align: 'center', width:40,valign: 'middle', sortable: false,
					formatter: function (value, row, index) {
						return index+1;
					}},
				{title: '触发质控项', field: 'qcDesc', align: 'left', width:100,valign: 'middle', sortable: false},
				{title: '质控项备注', field: 'qcMemo', align: 'left', width:100,valign: 'middle', sortable: false},
				{title: '规则描述', field: 'expDescription', align: 'left', width:180,valign: 'middle', sortable: false}
		        ],
			//注册加载子表的事件。注意下这里的三个参数！
			onExpandRow: function (index, row, $detail) {
				initSubTable(index, row, $detail);
			}
		});
    }, function (data) {
    });
	params.episodeId = $("#episodeId").val();
	ajax.set(params);
    ajax.start();
});
//初始化子表格(无线循环)
initSubTable = function (index, row, $detail) {
	//分值不为0时查询具体勾选的评估项，为0时直接返回评估项为空。
	if(row.riskScore != 0 ) {
        var itemIds = row.itemIds;
        var cur_table = $detail.html('<table></table>').find('table');
        $(cur_table).bootstrapTable({
            url: Sys.backendPath + "/manage/bloodEvalList",
            method: 'get',
            queryParams: {itemIds: itemIds},
            ajaxOptions: {itemIds: itemIds},
            uniqueId: "id",
            striped: false, //是否显示行间隔色
            pagination: false,//显示分页
            sidePagination: "client",
            pageNumber: 1,
            pageSize: 15,
            pageList: [10, 25],
            columns: [{
                field: 'id',
                title: '评估项代码',
                width: 30,
                align: 'center'
            }, {
                field: 'itemDesc',
                title: '评估项',
                width: 200,
                align: 'center'
            }],
            //无线循环取子表，直到子表里面没有记录
            onExpandRow: function (index, row, $Subdetail) {
                initSubTable(index, row, $Subdetail);
            }
        });
    }else{
        $detail.html("没有找到匹配的记录");
        $detail.css("text-align","center");
	}
};
